package com.platform.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.platform.comm.validation.constraints.Candidates;
import com.platform.comm.validation.groups.Insert;
import com.platform.enums.DictType;
import com.platform.comm.dto.BaseQo;
import com.platform.comm.enums.YnEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * Description: 字典组DTO
 *
 * @author libin Created on 2019/7/17
 **/
@EqualsAndHashCode(callSuper = true)
@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class DictGroupQo extends BaseQo {
    private static final long serialVersionUID = 4657053823333222228L;
    /**
     * 字典组中文值
     */
    @NotEmpty(message = "字典组名称不能为空", groups = Insert.class)
    @Size(max = 128, message = "字典组名称最多128个字符")
    private String groupName;

    /**
     * 字典组值
     */
    @NotEmpty(message = "字典组值不能为空", groups = Insert.class)
    @Size(max = 50, message = "字典组值最多128个字符")
    private String groupCode;

    /**
     * 所属模块
     */
    @Size(max = 100, message = "所属模块最多100个字符")
    private String model;

    /**
     * 信息状态
     */
    @Pattern(regexp = "[01YN]", message = "信息状态不合法")
    private YnEnum delFlag;

    /**
     * 字典类型 1: 系统字典 2：扩展字段
     */
    @Candidates(value = {"SYS", "EXT"}, message = "字典类型值不合法，可选值：['SYS', 'EXT']")
    private DictType dictType;

    @Override
    public void init() {
        this.setDelFlag(YnEnum.N);
        this.setCreateDate(LocalDateTime.now());
        this.setUpdateDate(LocalDateTime.now());
    }
}
